<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>绑定小程序</title>
  <meta name="renderer" content="webkit">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
  {include file="public/css"/}
</head>
<body>
  <div class="layui-fluid">
    <div class="layui-row layui-col-space15">
      <div class="layui-card layui-col-md12">
				<div class="layui-card-header">
					绑定小程序
					{if input('param.isopen')==1}<i class="layui-icon layui-icon-close" style="font-size:18px;font-weight:bold;cursor:pointer" onclick="closeself()"></i>{/if}
				</div>
				<div class="layui-card-body" pad15>
					<div class="layui-form form-label-w10" lay-filter="" style="margin-top:20px">
						<!-- <div class="layui-form-item">
							<div style="padding-left:20px;color:#f00">注意：选择该方式上传，如果您的小程序已授权，请先在[设置]-[第三方设置]中取消授权</div>
						</div> -->
						<div class="layui-form-item">
							<div style="padding-left:20px;font-weight:bold">一、填写小程序信息</div>
						</div>
						<div class="layui-form-item">
							<label class="layui-form-label">AppID：</label>
							<div class="layui-input-inline" style="width:200px">
								<input type="text" name="info[appid]" value="{$info.appid}" class="layui-input">
							</div>
							<div class="layui-form-mid layui-word-aux">登录小程序公众平台(mp.weixin.qq.com)[开发]-[开发设置]中查找</div>
						</div>
						<div class="layui-form-item">
							<label class="layui-form-label">AppSecret：</label>
							<div class="layui-input-inline" style="width:280px">
								<input type="text" name="info[appsecret]" value="{$info.appsecret}" class="layui-input">
							</div>
							<div class="layui-form-mid layui-word-aux">登录小程序公众平台(mp.weixin.qq.com)[开发]-[开发设置]中查找</div>
						</div>
						<div class="layui-form-item">
							<label class="layui-form-label">小程序名称：</label>
							<div class="layui-input-inline" style="width:280px">
								<input type="text" name="info[nickname]" value="{$info.nickname}" class="layui-input">
							</div>
						</div>
						<div class="layui-form-item">
							<label class="layui-form-label">小程序头像：</label>
							<input type="hidden" name="info[headimg]" id="headimg" lay-verType="tips" class="layui-input" value="{$info.headimg}">
							<button style="float:left;" type="button" class="layui-btn layui-btn-primary" upload-input="headimg" upload-preview="headimgPreview" onclick="uploader(this)">上传图片</button>
							<div id="headimgPreview" class="picsList-class-padding">
								<div class="layui-imgbox" style="width:100px;"><div class="layui-imgbox-img"><img src="{$info.headimg}"/></div></div>
							</div>
						</div>
						<div class="layui-form-item">
							<label class="layui-form-label">小程序码：</label>
							<input type="hidden" name="info[qrcode]" id="qrcode" lay-verType="tips" class="layui-input" value="{$info.qrcode}">
							<button style="float:left;" type="button" class="layui-btn layui-btn-primary" upload-input="qrcode" upload-preview="qrcodePreview" onclick="uploader(this)">上传图片</button>
							<div id="qrcodePreview" class="picsList-class-padding">
								<div class="layui-imgbox" style="width:100px;"><div class="layui-imgbox-img"><img src="{$info.qrcode}"/></div></div>
							</div>
						</div>
						<!-- <div class="layui-form-item">
							<label class="layui-form-label"></label>
							<div class="layui-input-inline">
								<button class="layui-btn layui-btn-primary" lay-submit lay-filter="submit_reg">确 定</button>
							</div>
						</div> -->
						<div class="layui-form-item">
							<div style="padding-left:20px;font-weight:bold">二、配置服务器域名</div>
						</div>
						<div class="layui-form-item" style="margin-bottom:0">
							<div class="layui-form-mid" style="margin-left:40px;">登录小程序公众平台(mp.weixin.qq.com)在[开发]-[开发管理]-[开发设置]-[服务器域名]，配置以下信息：</div>
						</div>
						<div class="layui-form-item" style="margin-bottom:0">
							<label class="layui-form-label">request合法域名：</label>
							<div class="layui-form-mid" style="width:200px;font-weight:bold">{$Think.const.PRE_URL2}</div>
							<div class="layui-form-mid layui-word-aux"></div>
						</div>
						<div class="layui-form-item" style="margin-bottom:0">
							<label class="layui-form-label">socket合法域名：</label>
							<div class="layui-form-mid" style="width:200px;font-weight:bold">wss://{:str_replace('https://','',PRE_URL2)}</div>
							<div class="layui-form-mid layui-word-aux"></div>
						</div>
						<div class="layui-form-item" style="margin-bottom:0">
							<label class="layui-form-label">uploadFile合法域名：</label>
							<div class="layui-form-mid" style="width:200px;font-weight:bold">{$Think.const.PRE_URL2}</div>
							<div class="layui-form-mid layui-word-aux"></div>
						</div>
						<div class="layui-form-item">
							<label class="layui-form-label">downloadFile合法域名：</label>
							<div class="layui-form-mid" style="width:200px;font-weight:bold">{$Think.const.PRE_URL2}</div>
							<div class="layui-form-mid layui-word-aux"></div>
						</div>
						 <div class="layui-form-item">
							<div style="padding-left:20px;font-weight:bold">三、配置消息推送</div>
						</div>
						<div class="layui-form-item" style="margin-bottom:5px">
							<div class="layui-form-mid" style="margin-left:40px;">登录微信小程序后台(mp.weixin.qq.com)在[开发]-[开发管理]-[开发设置]-[消息推送]，点击启用，配置以下信息：</div>
						</div>
						<div class="layui-form-item" style="margin-bottom:5px">
							<div class="layui-form-mid" style="margin-left:40px;color:red">注意：填写完成以下信息后需先点击下方保存按钮，再在小程序后台点击提交按钮，否则会校验失败。</div>
						</div>
						<div class="layui-form-item" style="margin-bottom:5px">
							<label class="layui-form-label">URL(服务器地址)：</label>
							<div class="layui-form-mid" style="width:700px;font-weight:bold" id="fwqurl">{$Think.const.PRE_URL2}/?s=/ApiWechat/index/appid/{$info.appid}</div>
							<div class="layui-form-mid layui-word-aux"></div>
						</div>
						<div class="layui-form-item" style="margin-bottom:5px">
							<label class="layui-form-label">Token(令牌)：</label>
							<div class="layui-input-inline" style="width:400px">
								<input type="text" name="info[token]" value="{$info.token}" class="layui-input">
							</div>
							<div class="layui-form-mid layui-word-aux"></div>
						</div>
						<div class="layui-form-item" style="margin-bottom:5px">
							<label class="layui-form-label">EncodingAESKey(消息加密密钥)：</label>
							<div class="layui-input-inline" style="width:400px">
								<input type="text" name="info[key]" value="{$info.key}" class="layui-input">
							</div>
						</div>
						<div class="layui-form-item" style="margin-bottom:5px">
							<label class="layui-form-label">消息加密方式：</label>
							<div class="layui-form-mid" style="width:200px;font-weight:bold">安全模式</div>
						</div>
						<div class="layui-form-item" style="margin-bottom:5px">
							<label class="layui-form-label">数据格式：</label>
							<div class="layui-form-mid" style="width:200px;font-weight:bold">XML</div>
						</div>

						<!-- <div class="layui-form-item">
							<div style="padding-left:20px;font-weight:bold">三、下载小程序代码</div>
						</div>
						<div class="layui-form-item">
							<label class="layui-form-label">小程序代码：</label>
							<a class="layui-btn layui-btn-normal" href="javascript:void(0)" onclick="downloadop()" style="float:left">打包下载</a>
							<div class="layui-form-mid layui-word-aux" style="margin-left:10px"> 下载后解压压缩包得到 <span style="color:green;font-weight:bold">wx_{$set.aid}</span> 文件夹</div>
						</div>
						<div class="layui-form-item">
							<div style="padding-left:20px;font-weight:bold">四、用开发者工具上传代码</div>
						</div>
						<div class="layui-form-item">
							<label class="layui-form-label">1、安装开发者工具：</label>
							<a class="layui-btn layui-btn-primary" href="https://developers.weixin.qq.com/miniprogram/dev/devtools/download.html" target="_blank" style="float:left">去下载</a>
							<div class="layui-form-mid layui-word-aux" style="margin-left:10px">如果未安装请下载安装</div>
						</div>
						<div class="layui-form-item">
							<label class="layui-form-label">2、导入代码：</label>
							<div class="layui-form-mid">打开开发者工具，依次选择[小程序]-[+]-[导入项目]-[目录]，选择第三步解压得到的文件夹“wx_{$set.aid}”，点击右下角[导入]按钮</div>
						</div>
						<div class="layui-form-item">
							<label class="layui-form-label"3、上传代码：</label>
							<div class="layui-form-mid">在开发者工具右侧点击上传按钮进行上传代码，设置版本号点击上传</div>
						</div>
						<div class="layui-form-item">
							<div style="padding-left:20px;font-weight:bold">五、提交审核发布上线</div>
						</div>
						<div class="layui-form-item">
							<div class="layui-form-mid" style="margin-left:40px">进入小程序公众平台(mp.weixin.qq.com)点击[版本管理]进行提交审核，等待审核通过后点击发布上线即可</div>
						</div> -->
						<div class="layui-form-item">
							<label class="layui-form-label"></label>
							<div class="layui-input-inline" style="width:500px">
								<button class="layui-btn layui-btn-normal" lay-submit lay-filter="submit_reg">保 存</button>
								<button class="layui-btn layui-btn-primary" type="button" id="uploadjstxt">上传域名校验文件</button>
							</div>
						</div>
					</div>
				</div>
			</div>
    </div>
  </div>
	{include file="public/js"/}
	<script>
	
	$(".layui-form input[name='info[appid]']").bind("input change propertychange",function(event){
		var appid = $(this).val();
		$('#fwqurl').text('{$Think.const.PRE_URL2}/?s=/ApiWechat/index/appid/'+appid);
	})
	function downloadop(){
		var index = layer.load();
		$.get('',{op:'download'},function(data){
			layer.close(index);
			dialog(data.msg,data.status,data.url);
		})
	}
	layui.form.on('submit(submit_reg)', function(obj){
		var field = obj.field
		field.op = 'setappid';
		$.post('',field,function(data){
			dialog(data.msg,data.status,'{:url('index')}');
		})
	})
	layui.upload.render({
    elem: '#uploadjstxt', //绑定元素
    url: "{:url('uploadjstxt')}", //上传接口
		exts:'txt',
    done: function(res){
      //上传完毕回调
			console.log(res)
			dialog(res)
    },
    error: function(){
      //请求异常回调
    }
  });
  </script>
	{include file="public/copyright"/}
</body>
</html>